<template>
  <div class="music-item" @click="handelMusicItem">
    <div class="pic">
      <img v-lazy="img" />
      <div class="desc-wrap">
        <span class="desc">{{desc}}</span>
      </div>
      <playicon :size="36" class="icon" />
    </div>
    <p class="name">{{name}}</p>
  </div>
</template>

<script>
import playicon from '../playicon/playicon'
export default {
  name: '',
  data () {
    return {

    };
  },
  methods: {
    handelMusicItem () {
      this.$emit('handelMusicItem', this.id)
    }
  },
  props: ['id', 'img', 'name', 'desc'],
  components: {
    playicon
  }
}

</script>
<style lang='less' scoped>
.music-item {
  display: inline-block;
  width: 19%;
  margin-right: 1%;
  margin-bottom: 20px;
  box-sizing: border-box;
  &::after {
    margin-right: 0;
  }
  .pic {
    width: 100%;
    position: relative;

    overflow: hidden;
    img {
      width: 100%;
      height: 100%;
      border-radius: 10px;
    }
    &:hover {
      .desc-wrap {
        transform: translateY(0);
        transition: all 0.5s;
      }
      .music-icon {
        opacity: 1;
        transition: all 0.5s;
      }
    }
    .desc-wrap {
      width: 100%;
      transform: translateY(-100%);
      transition: all 0.5s;
      color: #fff;
      position: absolute;
      top: 0;
      left: 0;
      font-size: 12px;
      .desc {
        display: inline-block;
        width: 100%;
        background-color: rgba(0, 0, 0, 0.4);
        padding: 5px;
        box-sizing: border-box;
      }
    }
    .icon {
      position: absolute;
      bottom: 10px;
      right: 10px;
    }
  }
  .name {
    font-size: 12px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}
</style>
